<html>
<head><meta charset="utf-8"><title>Scalar::from_u128? · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html">Scalar::from_u128?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219266423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219266423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219266423">(Dec 08 2020 at 21:38)</a>:</h4>
<p>The <code>Scalar</code> type in <code>rustc_middle/src/mir/interpret/value.rs:104</code> says that it can represent a small chunk of an <code>Allocation</code> up to 8 bytes in size. So how come the <code>data</code> field is a <code>u128</code>? </p>
<p>In my custom rustc fork, i want to add a const intrinsic that returns a u128, is it possible to add <code>Scalar::from_u128</code> constructor like the rest, or will I break things in ways in which I don't understand? Thanks</p>



<a name="219308169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219308169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219308169">(Dec 09 2020 at 08:28)</a>:</h4>
<p>oh... that sounds like a bug in the documentation</p>



<a name="219308198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219308198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219308198">(Dec 09 2020 at 08:28)</a>:</h4>
<p><code>Scalar</code> can represent integers up to <code>u128</code></p>



<a name="219388486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219388486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219388486">(Dec 09 2020 at 19:48)</a>:</h4>
<p>Ah I see. Thanks. Shall I raise a PR for this?</p>



<a name="219444110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219444110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219444110">(Dec 10 2020 at 08:41)</a>:</h4>
<p>That would be great!</p>



<a name="219772736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219772736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219772736">(Dec 13 2020 at 18:16)</a>:</h4>
<p>Yeah we were probably just too lazy to all the to/from methods for u128 and i128 ;)</p>



<a name="219772776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Scalar%3A%3Afrom_u128%3F/near/219772776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Scalar.3A.3Afrom_u128.3F.html#219772776">(Dec 13 2020 at 18:16)</a>:</h4>
<p>would be a good idea to get that set of methods completed</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>